//
//  AttributionAreaCell.m
//  MonitoringNetwork
//
//  Created by admin on 2017/12/2.
//  Copyright © 2017年 wtmcxlm. All rights reserved.
//

#import "AttributionAreaCell.h"


@interface AttributionAreaCell()
@property (nonatomic,strong)UILabel *areaLabel;
@property (nonatomic,strong)UILabel *carNumLabel;
@property (nonatomic,strong)UILabel *yesterdayLabel;
@property (nonatomic,strong)UILabel *todayLabel;
@end


@implementation AttributionAreaCell

- (void)awakeFromNib {
    [super awakeFromNib];
    // Initialization code
}

- (void)setSelected:(BOOL)selected animated:(BOOL)animated {
    [super setSelected:selected animated:animated];

}
- (instancetype)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reuseIdentifier
{
    self = [super initWithStyle:style reuseIdentifier:reuseIdentifier];
    if (self) {
        
        [self setUpUI];
    }
    return self;
}
- (void)setUpUI
{

    UIView *lineView = [UIView new];
    [self addSubview:lineView];
    lineView.backgroundColor = [UIColor colorWithRed:0.88f green:0.88f blue:0.88f alpha:1.00f];
    [lineView mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.right.bottom.mas_equalTo(self);
        make.height.mas_equalTo(0.5);
    }];
    
    _areaLabel = [UILabel new];
    _areaLabel.textAlignment = NSTextAlignmentCenter;
    _areaLabel.font = [UIFont systemFontOfSize:NormalFontSize];
    _areaLabel.text = @"华北大区";
    [self.contentView addSubview:_areaLabel];
    [_areaLabel mas_makeConstraints:^(MASConstraintMaker *make) {
        make.centerY.mas_equalTo(self.contentView);
        make.width.mas_equalTo(kScreenWidth*0.25);
        make.left.mas_equalTo(self.contentView);
    }];
    
    _carNumLabel = [UILabel new];
    _carNumLabel.textAlignment = NSTextAlignmentCenter;
    _carNumLabel.font = [UIFont systemFontOfSize:NormalFontSize];
    _carNumLabel.text = @"30000";
    [self.contentView addSubview:_carNumLabel];
    [_carNumLabel mas_makeConstraints:^(MASConstraintMaker *make) {
        make.centerY.mas_equalTo(self.contentView);
        make.width.mas_equalTo(kScreenWidth*0.25);
        make.left.mas_equalTo(self.contentView).offset(kScreenWidth*0.25);
    }];
    
    _yesterdayLabel = [UILabel new];
    _yesterdayLabel.textAlignment = NSTextAlignmentCenter;
    _yesterdayLabel.font = [UIFont systemFontOfSize:NormalFontSize];
    _yesterdayLabel.text = @"20000";
    [self.contentView addSubview:_yesterdayLabel];
    [_yesterdayLabel mas_makeConstraints:^(MASConstraintMaker *make) {
        make.centerY.mas_equalTo(self.contentView);
        make.width.mas_equalTo(kScreenWidth*0.25);
        make.left.mas_equalTo(self.contentView).offset(kScreenWidth*0.5);
    }];
    
    _todayLabel = [UILabel new];
    _todayLabel.textAlignment = NSTextAlignmentCenter;
    _todayLabel.font = [UIFont systemFontOfSize:NormalFontSize];
    _todayLabel.text = @"20000";
    [self.contentView addSubview:_todayLabel];
    [_todayLabel mas_makeConstraints:^(MASConstraintMaker *make) {
        make.centerY.mas_equalTo(self.contentView);
        make.width.mas_equalTo(kScreenWidth*0.25);
        make.left.mas_equalTo(self.contentView).offset(kScreenWidth*0.75);
    }];
    
}

- (void)layoutSubviews
{
    [super layoutSubviews];
    _areaLabel.text = _model.name;
    if (!_model.carNum) {
        _carNumLabel.text = @"0";
    }else{
        _carNumLabel.text = _model.carNum;
    }
    _todayLabel.text = [NSString stringWithFormat:@"%.2lf",[_model.todayMileage doubleValue]];
    _yesterdayLabel.text = [NSString stringWithFormat:@"%.2lf",[_model.yestodayMileage doubleValue]];
}

@end
